package com.mdlib.helper.ui.adapter;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ljlib.help.R;
import com.mdlib.helper.model.entity.AddressEntity;

import java.util.List;

/**
 * 作者：HQY on 16/11/16 10:57
 * 邮箱：hqy_xz@126.com
 */

public class AddressAdapter extends BaseQuickAdapter<AddressEntity> {


    public AddressAdapter(List<AddressEntity> data) {
        super(R.layout.item_address, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, AddressEntity addressEntity) {

        baseViewHolder.setText(R.id.tv_address_nickname, addressEntity.getName())
                .setText(R.id.tv_address, addressEntity.getAddress())
                .setText(R.id.tv_address_phone, addressEntity.getPhoneNumber())
                .addOnClickListener(R.id.iv_address_edit)
                .addOnClickListener(R.id.iv_address_delete);
        if (addressEntity.getType() == 1) {
            baseViewHolder.getView(R.id.iv_address_default).setVisibility(View.VISIBLE);
        } else {
            baseViewHolder.getView(R.id.iv_address_default).setVisibility(View.GONE);
        }
        if (addressEntity.isHide()) {
            baseViewHolder.getView(R.id.ll_address_eidt).setVisibility(View.VISIBLE);
        } else {
            baseViewHolder.getView(R.id.ll_address_eidt).setVisibility(View.GONE);
        }
    }
}
